﻿using MyToDo.Content.UnitOfWork.Collections;
using MyToDo.Dtos;
using MyToDo.Shared.Parameters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BZhanHengjicvWPF.Services
{
    public class ToDoService : BaseService<ToDoDto>, IToDoService
    {
        private readonly HttpRestClient client;

        public ToDoService(HttpRestClient client) : base(client, "ToDo")
        {
            this.client = client;
        }
        public async Task<ApiResponse<PagedList<ToDoDto>>> GetAllFilterAsync(ToDoParameter toDoParameter)
        {
            BaseRequest request = new BaseRequest();
            request.Method = RestSharp.Method.GET;
            request.Route = $"api/ToDo/GetAll?PageIndex={toDoParameter.PageIndex}" +
                $"&PageSize={toDoParameter.PageSize}" +
               $"&Search={toDoParameter.Search}" +
               $"&Status={toDoParameter.Status}";
            return await client.ExcuteAsync<PagedList<ToDoDto>>(request);
        }

        public async Task<ApiResponse<SummaryDto>> SummaryAsync()
        {
            BaseRequest request = new BaseRequest();
            request.Method= RestSharp.Method.GET;
            request.Route = $"api/ToDo/Summary";
            return await client.ExcuteAsync<SummaryDto>(request);
        }
    }
}

